<?php
namespace Home\Controller;
use Think\Controller;
class GerencenterController extends PublicController {
	
    public function userpro(){
		
		$this->assign("k",CONTROLLER_NAME);
		$this->assign("f",ACTION_NAME);
		
		
		$this->display();
    }
	//个人资料完善页面
	public function showpro(){
		//var_dump($_POST);
		$name = $_SESSION['name'];
		$info = M('user')->where("name = '$name'")->find();
		//var_dump($info);
		$info = M('user')->where("name = '$name'")->save($_POST);
		if($info){
			$this->redirect('Gerencenter/usercenter');
		}else{
			$this->error();
		}
	}
	//个人信息+订单页面
	public function usercenter(){
		
		$this->assign("k",CONTROLLER_NAME);
		$this->assign("f",ACTION_NAME);
		$this->display();
	}
	//添加收货地址页面
	public function shopaddress(){
		$this->address();
		$this->display();
	}
	//添加收货地址方法
	public function addAddress(){
		//var_dump($_POST);
		$info = M('shopaddress')->add($_POST);
		//var_dump($info);
		if($info){
			$this->redirect('Gerencenter/shopaddress');
		}
	}
	//收货地址列表输出
	public function address(){
		$addr = M('shopaddress')->select();
		$this->assign("addr",$addr);
	
	}
	//修改收货地址模板
	public function editAddress(){
		$this->wxjshow();
		$id = $_GET['uid'];
		$editinfo = M('shopaddress')->where("id = $id")->find();
		$this->assign("editinfo",$editinfo);
		$this->display();
	}
	//修改收货地址
	public function edit(){
		$id = $_POST['id'];
		M('shopaddress')->where("id = $id")->save($_POST);
		$this->redirect('Gerencenter/shopaddress');
		
	}
}